﻿// For an introduction to the Page Control template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function () {
    "use strict";

    WinJS.UI.Pages.define("/pages/goalTab/goalTab.html", {
        // This function is called whenever a user navigates to this page. It
        // populates the page elements with the app's data.
        ready: function (element, options) {
            attachCommontHandlres();
            document.getElementById("inpt_g_dist").addEventListener("change", updateSpeed, false);
            document.getElementById("inpt_g_time").addEventListener("change", updateSpeed, false);
            document.getElementById("slct_dist").addEventListener("change", updateSpeed, false);
            document.getElementById("slct_time").addEventListener("change", updateSpeed, false);
        },

        unload: function () {
            // TODO: Respond to navigations away from this page.
        },

        updateLayout: function (element, viewState, lastViewState) {
            /// <param name="element" domElement="true" />

            // TODO: Respond to changes in viewState.
        }
    });
})();
function updateSpeed() {
    var d = getFloatValue("inpt_g_dist");
    d = getDistance(d);
    var t = getFloatValue("inpt_g_time");
    t = getTopTime(t);
    var s = getSpeed(d, t);
    setFloatValue("inpt_speed", s);
    setFloatValue("inpt_time", getNikeStyleSpeed(s));
    setFloatValue("inpt_oposit", getOppositSpeed(s));
}